<?php
//Desktop_Create
//This function returns the HTML code used for User's Desktop Features
//@author : 3dward
//arguments : 0

function Desktop_Create()
{
	$return = '<ul class="Desktop_Icon">';
	$dir = @opendir("./modules/");
	
	while ($file = readdir($dir))
	{
		//If a module is found (actually no asc or desc sort)
		if (is_dir("./modules/".$file) && $file != "." && $file != ".." && file_exists("./modules/".$file."/conf.xml"))
		{
			//$prgmdata will contain every informations stored in the conf.xml file
			$prgmdata = Module_XMLConf_Load($file);
			//If initfile exists too
			if (file_exists("./modules/".$file."/".$prgmdata['initfile']))
			{
				//We add an <li> for the current application
				$return .= Desktop_IconLi_Create($file,$prgmdata);
				//And then we add the desktopicon (default or not)
				if ($prgmdata["desktopicon"] != "default")
				{
					$return .= Desktop_Icon_Create($file,'./modules/'.$file.$prgmdata["desktopicon"]);
				}
				else
				{
					$return .= Desktop_Icon_Create($file,'./skins/menu/icone.png');
				}
				//Now, adding the Application name
				$return .= '<br /><span class="Desktop_IconName">'.$prgmdata["appname"].'</span></div></li>';
			}
		}
	}
	
	closedir($dir);
	$return .= '</ul>';
	
	return $return;
	
}

//Desktop_IconLi_Create
//This function returns the <li> element of the User's Application displayed on the Desktop
//@author : 3dward
//arguments : 	1 : application folder name(used as an id)
//				2 : application data array


function Desktop_IconLi_Create($title,$datas)
{

//Show and Hide functions are used for Icon Background features
//CreateWindow tries to create the application's window
//Dblclickicone is a visual feature (actually fade out and fade in)

return '<li	style="z-index:0;"
		onmouseover="show(\'Desktop_IconBackground'.$title.'\')"
		onmouseout="hide(\'Desktop_IconBackground'.$title.'\')"
		ondblclick="dblclickicone(\'Desktop_Icon'.$title.'\');
					CreateWindow(\''.$title.'\','.$datas["width"].','.$datas["height"].','.$datas["resizable"].','.$datas["movable"].','.$datas["autofullscreen"].',\''.$datas["programicon"].'\',\''.$datas["initfile"].'\');
					">
		'.Desktop_IconBackground_Create($title);
		
}

//Desktop_IconBackground_Create
//This function returns the HTML code used for Desktop Icon Background
//@author : 3dward
//arguments :	1 : application folder name (used as an id)

function Desktop_IconBackground_Create($title) {

return	'<div id="Desktop_IconBackground'.$title.'" class="Desktop_IconBackground"></div>
		<div class="Desktop_IconDiv" >';
		
}

//Desktop_Icon_Create
//This function return the HTML code of a Desktop Icon
//@author : 3dward
//arguments :	1 : application folder name (used as an id)
//				2 : icon path

function Desktop_Icon_Create($title,$url) {

return 	'<img id="Desktop_Icon'.$title.'"
		src="'.$url.'"
		alt="'.$title.'"
		title="'.$title.'"	/>';
		
}

?>